<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
        PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml"
      xmlns:s="http://jboss.com/products/seam/taglib"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich">

<ui:composition template="#{store.templatePath}/template.xhtml">
    <ui:define name="title">#{messages.cart}</ui:define>

    <ui:define name="cart"></ui:define>

    <ui:define name="body">

        <div class="orderBreadcrumbs"><span class="current">#{messages.cart}</span> → <span>#{messages.authorization}</span> → <span>#{messages.delivery}</span> → <span>#{messages.pay}</span> → <span>#{messages.confirmation}</span></div>



        <f:subview id="emptycart" rendered="#{cart.isEmpty()}">
            <p>#{messages.cartIsEmpty}</p>

            <h:form id="EmptyCartForm">
                <s:link view="/browse.xhtml" value="← #{messages.continueShopping}" propagation="none"><f:param
                        name="cat" value=""/></s:link>
            </h:form>
        </f:subview>

        <f:subview id="cartdetails" rendered="#{!cart.isEmpty()}">

            <a4j:form id="cartForm">

                <h:dataTable id="cartTable"
                             styleClass="cartTable"
                             columnClasses="cartCell,cartCell,cartCell,cartCell,cartCell"
                             value="#{cart.order.lines}" var="l"
                             cellspacing="1">

                    <h:column>
                        <s:link view="/product.xhtml" propagation="none">
                            <f:param name="cat" value="#{l.product.categories.toArray()[0].id}"/>
                            <f:param name="alias" value="#{l.product.urlAlias}"/>
                            <h:graphicImage value="#{l.product.urlImageSmall}"
                                            alt="#{l.product.name}"
                                            rendered="#{l.product.urlImageSmall != null}" styleClass="cartProductImage" />
                            <h:graphicImage value="/r/pi/#{l.product.urlAlias}-s.jpg"
                                            alt="#{l.product.name}"
                                            rendered="#{l.product.urlImageSmall == null}" styleClass="cartProductImage" /><br/>
                        </s:link>
                    </h:column>

                    <h:column>
                        <f:facet name="header">
                            #{messages.product}
                        </f:facet>
                        <s:link view="/product.xhtml" value="#{l.product.name}" propagation="none">
                            <f:param name="cat" value="#{l.product.categories.toArray()[0].id}"/>
                            <f:param name="alias" value="#{l.product.urlAlias}"/>
                        </s:link>
                        <div class="product-description">#{l.product.description}</div>
                    </h:column>

                    <h:column headerClass="quantityColumn">
                        <f:facet name="header">
                            #{messages.quantity}
                        </f:facet>
                        <rich:inputNumberSpinner value="#{l.quantity}" minValue="0" maxValue="1000000" cycled="false" inputSize="1">
                            <a4j:support event="onchange" action="#{cart.updateTotals()}" reRender="cartForm" />
                        </rich:inputNumberSpinner>
                        <f:facet name="footer">
                            #{messages.subTotal}:
                        </f:facet>
                    </h:column>

                    <h:column headerClass="priceColumn" footerClass="cartTotal">
                        <f:facet name="header">
                            #{messages.cost}
                        </f:facet>
                        <div class="product-price">
                            <span class="product-price-digits">
                                <h:outputText value="#{l.quantity*l.product.price}">
                                    <f:convertNumber type="currency" currencySymbol=""/>
                                </h:outputText></span> руб.
                        </div>
                        <f:facet name="footer">
                            <h:outputText value="#{cart.subTotal}">
                                <f:convertNumber type="currency" currencySymbol="р."/>
                            </h:outputText>
                        </f:facet>


                    </h:column>


                </h:dataTable>






                <h:commandButton action="#{cart.reset()}" value="#{messages.resetCart}"/>

                <s:button view="/order/auth.xhml" value="#{messages.checkout} →" propagation="none"/><br /><br />

                <s:link view="/browse.xhtml" value="← #{messages.continueShopping}" propagation="none"><f:param
                        name="cat" value=""/></s:link>


            </a4j:form>
        </f:subview>


    </ui:define>

</ui:composition>

</html>